package twLogicQuizSubmission

import org.springframework.cloud.contract.spec.Contract

Contract.make {
    request {
        method("GET")
        url("/api/tw-logic-quiz-submission") {
            queryParameters {
                parameter("assignmentId", 1)
                parameter("quizId", 1)
            }
        }
        headers {
            header("id", 1)
            contentType(applicationJsonUtf8())
        }
    }
    response {
        status(200)
        body("""
        {
            "id":1,
            "assignmentId":1,
            "quizId":1,
            "startTime":"2018-09-11T07:36:06.000+0000",
            "status":"finished",
            "twlogicQuizItemAnswer":[],
            "twexampleLogicQuizItemAnswer":[]
        }
        """)
        bodyMatchers {
            jsonPath('$.id', byRegex(number()))
            jsonPath('$.assignmentId', byRegex(number()))
//            jsonPath('$.userId', byRegex("${number()}|null"))
            jsonPath('$.quizId', byRegex(number()))
            jsonPath('$.startTime', byType())
            jsonPath('$.status', byType())
            jsonPath('$.twlogicQuizItemAnswer', byType())
            jsonPath('$.twexampleLogicQuizItemAnswer', byType())
        }
        headers {
            contentType(applicationJsonUtf8())
        }
    }
}
